package hu.tortavar2.server;

import hu.tortavar2.shared.Product;

import java.io.IOException;
import java.util.logging.Logger;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@SuppressWarnings("serial")
public class ServeDetailView extends HttpServlet {
	
	private final SiteServiceImpl siteService = new SiteServiceImpl();
	private static final Logger log = Logger.getLogger(ServeDetailView.class.getName());
	Product product = new Product();

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws IOException, ServletException {
		try {
			product = siteService.getProduct(request.getParameter("t"));
			request.setAttribute("product", product);
			request.setAttribute("url", request.getRequestURL());
			request.getRequestDispatcher("/Tortavar2.jsp").forward(request, response);
			
//			PrintWriter out = response.getWriter();  
//			out.print(product.getProductName());
			
		} catch (Exception e) {
			throw new ServletException("Nem sikerült a termékadat letöltése", e);
		}
	}

}
